<template>
	<div class="mybox">
				<h3 style="margin:20px auto 40px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;员工离职申请</h3>
				<el-form class="infro" label-width="100px" label="员工离职">
					<el-form-item label="员工编号  :">
						<el-input v-model="me.eid" autocoplete="off" disabled></el-input>
					</el-form-item>
					<el-form-item label="姓    名  :">
						<el-input v-model="me.ename" autocoplete="off" disabled></el-input>
					</el-form-item>
					<el-form-item label="当前部门  :">
						<el-input v-model="me.dname" autocoplete="off" disabled></el-input>
					</el-form-item>
					<el-form-item label="申请时间  :">
						<el-input v-model="now" autocoplete="off" disabled></el-input>
					</el-form-item>
					<el-form-item label="离职原因  :">
						<el-input type="textarea" v-model="infro" autocoplete="off" style="width:520px" @change="checkReason"></el-input>
					</el-form-item>
					<br/>
					<br/>
					<el-button type="success" @click="sureChange" :disabled="disable">提交</el-button>
				</el-form>
			</div>
		</template>
		
		<script>
			export default {
				data() {
					return {
						me:this.$parent.$parent.$parent.$parent.emp,
						now:new Date().toLocaleDateString(),
						depts:[],
						infro:'',
						disable:true,
					};
				},
				
				methods:{			
					sureChange(){
						this.$confirm(
							"你确定提交吗？",
							"温馨提示",
							{
									confirmButtonText:'确定',
									cancelButtonText:'取消',
									type:'warning'
							}
						).then(()=>{
							if(this.me.job=="stuff"){
								this.$axios.post("dimission?eid="+this.me.eid+"&predno="+this.me.deptno+"&changeDate="+this.now+"&infro="+this.infro+"&state=0").then(v=>{
									console.log(v)
									if(v.data){
										this.$message({
											type:"success",
											message:"提交成功！"
										}); 
										this.$router.push("/home/");
									}else{
										alert("出错了！！");
									}
								}).catch(ex=>{
									alert("出错了！"+ex);
								})
							}else if(this.me.job=="manager"){
								this.$axios.post("dimission2?eid="+this.me.eid+"&predno="+this.me.deptno+"&changeDate="+this.now+"&infro="+this.infro+"&state=0").then(v=>{
									console.log(v)
									if(v.data){
										this.$message({
											type:"success",
											message:"提交成功！"
										}); 
										this.$router.push("/home/");
									}else{
										alert("出错了！！");
									}
								}).catch(ex=>{
									alert("出错了！"+ex);
								})
							}
							
						}).catch(()=>{
							this.$message({
								type:"info",
								message:"你已经取消"
							});
						})
					},
					checkReason(){
						this.disable=true;
						if(this.infro!=''){
							this.disable=false;
						}
					}
				}
			}
		</script>
	
	<style>
	.mybox{
			width:900px;
			height:600px;
			border:1px solid #FFFFFF;
			background:#FFFFFF;
		}
		.mybox .infro .el-form{
			margin:0 auto;
			width:900px;
		}
		.mybox .el-input{
			width:200px;
			float:left;
		}
		.mybox .infro .el-form-item{
			display:inline-block;
		}
		.infro .el-form-item{
			text-align: center;
		}
		.infro .el-input{
			width:210px;
		}
	</style>
	